import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class NOT here.
 * 
 * @author Christian Pérez Zavalija
 * @version 25-Jun-2013
 */
public class NOT extends Circuit
{
    private GreenfootImage imgNot;
    
    /**
     * Load image and displays.
     */
    public NOT()
    {
        imgNot=new GreenfootImage("NOT.png");
        setImage(imgNot);
    }
    
    
    /**
     * The image is scale in 50%
     */
    public void scale()
    {
        imgNot.scale(imgNot.getWidth()-50,imgNot.getHeight()-40);
    }
    
    /**
     * It drives the circuit logic Not(7404) in the input pins for establish a charge on the respective output pin.
     * 
     * @param into number pinA and number pin B.
     */
    public void logicAND(int A)
    {
        if(pins[A].charge==0)
            pins[A+1].charge=1;
        else
            pins[A+1].charge=0;
    }
    
    /**
     * Method calls the act () of its superclass. Check if the circuit is energized and if the
     * values ​​of the input pins are different garbage charge.
     */
    public void act() 
    {
        super.act();
        if(pins[6].charge==0&&pins[7].charge==1){
            if(pins[0].charge<2)
                this.logicAND(0);
            if(pins[2].charge<2)
                this.logicAND(2);
            if(pins[4].charge<2)
                this.logicAND(4);
            if(pins[8].charge<2)
                this.logicAND(8);
            if(pins[10].charge<2)
                this.logicAND(10);
            if(pins[12].charge<2)
                this.logicAND(12);
        }
    }    
}
